﻿using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
using NHibernate;
using Models;
using System;
using OnTheWay;
using System.Reflection;

namespace BlackMofo.DAL.Mappers
{
    public class BaseMapper<T> : ClassMapping<T> where T : OnTheWay.Models.Model
    {
        public BaseMapper()
        {
            //ID
            this.Id(x => x.ID, map => map.Generator(Generators.Assigned));

            //Name
            this.Property(x => x.Name, map =>
            {
                map.Type(NHibernateUtil.String);
                map.Length(100);
                map.NotNullable(true);
            });

            //Remark
            this.Property(x => x.Remark, map =>
            {
                map.Type(NHibernateUtil.String);
                map.Length(100);
                map.NotNullable(false);
            });

            //RegDate
            this.Property(x => x.RegDate, map =>
            {
                map.Type(NHibernateUtil.DateTime);
                map.Length(100);
                map.NotNullable(true);
            });

        }
    }
}
